//
//  CMMySettingCtrl.m
//  CreditManger
//
//  Created by chaiyanan on 15/11/2.
//  Copyright © 2015年 jinxin. All rights reserved.
//

#import "CMMySettingCtrl.h"
#import "CMLogoutParam.h"
#import "CMLogoutParser.h"
#import "CMLoginManager.h"
#import "CMFPhoneNumCtrl.h"

@interface CMMySettingCtrl ()

@end

@implementation CMMySettingCtrl

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:YES];
     self.navigationController.navigationBarHidden = YES;
}

- (void)tapDone:(UITapGestureRecognizer *)recongnizer
{
    [self.view endEditing:YES];
}

#pragma mark - action

- (IBAction)clickToQuitLogin:(UIButton *)sender
{
    [self requestTologout];
}

- (IBAction)clickToModifyPwd:(id)sender
{
    CMFPhoneNumCtrl *phoneNumCtrl = [[CMFPhoneNumCtrl alloc]initWithNibName:NSStringFromClass([CMFPhoneNumCtrl class]) bundle:nil];
    phoneNumCtrl.isModify = YES;
    [self.navigationController pushViewController:phoneNumCtrl animated:YES];
    
}

#pragma mark - request

- (void)requestTologout
{
    CMLogoutParam *param = [[CMLogoutParam alloc]init];
    param.token = [CMLoginManager sharedCMLoginManager].currentUserInfo.token;
    param.uid = [CMLoginManager sharedCMLoginManager].currentUserInfo.uid;
    
    CMLogoutParser *parser = [[CMLogoutParser alloc]init];
    [NetCenter postDataFromURL:Method_logout params:param parser:parser result:^(ParserResult *myResult) {
        if (myResult.code==0)
        {
            [CMLoginManager didLoginOut];
        }
        else
        {
            DISSMISS_ERR(myResult.message);
        }
        
    } failure:^(NSError *error) {
        DISSMISS_ERR([error description]);
    }];
}

@end
